import {login} from './service'
export default {
  namespace: 'login',
  state:{
    isLogin: false,
    data:{}
  },
  effects: {
    * login ({ payload }, { call, put}) {
      yield put({
        type: 'app/getChange',
        payload: {
          requestState: true
        }
      })
      const { data } = yield call(login, payload)
      yield put({
        type: 'app/getChange',
        payload: {
          requestState: false
        }
      })
      yield put({
        type: 'changeLogin',
        payload: {data}
      })
    }
  },
  reducers: {
    changeLogin (state, { payload }) {
      return {
        ...state,
        isLogin: true,
        ...payload
      }
    }
  }
}